'use strict';

module.exports = app => {
  const { INTEGER, DATE, TINYINT, DECIMAL } = app.Sequelize;
  const Order = app.model.define('orders', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    user_id: { //
      type: INTEGER,
      allowNull: false,
      comment: '用户id',
    },
    goods_id: {
      type: INTEGER,
      allowNull: false,
      comment: '商品id',
    },
    total: {
      type: DECIMAL(10, 2),
      allowNull: false,
      comment: '订单总金额',
    },
    status: {
      type: TINYINT,
      allowNull: false,
      defaultValue: 0,
      comment: '订单状态(0:未支付，1已支付，2已发货，3已签收，4取消)',
    },
    created_at: DATE,
    updated_at: DATE,
  });

  return Order;
};
